package com.nebula.tlggoods.controller;

import com.nebula.tlggoods.entity.Carts;
import com.nebula.tlggoods.service.CartsService;
import com.nebula.tlggoods.tools.Record;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 购物车控制层
 */
@RestController
public class CartsController {

    @Resource
    private CartsService cartsService;

    /**
     * 加入购物车
     *
     * @param carts 对象
     * @return
     */
    @PostMapping("/addCarts")
    @ApiOperation(notes = "加入购物车", value = "加入购物车")
    public Record addCarts(@RequestBody Carts carts) {
        return cartsService.addCarts(carts);
    }

    /**
     * 查询购物车商品
     * @param carts
     * @return
     */
    @PostMapping("/getCartsGoods")
    @ApiOperation(notes = "查询购物车商品", value = "查询购物车商品")
    public Record getCartsGoods(@RequestBody Carts carts) {
        return cartsService.findCartsGoods(carts);
    }


    /**
     * 修改购物车商品数量
     *
     * @param carts
     * @return
     */
    @PutMapping("/modifyCartsGoodsQuantity")
    @ApiOperation(notes = "修改购物车商品数量", value = "修改购物车商品数量")
    public Record modifyCartsGoodsQuantity(@RequestBody Carts carts) {
        return cartsService.modifyCartsGoodsQuantity(carts);
    }

}